using System;
using System.Collections.Generic;
using System.Text;
using Utility;
using DAL;
using Entites;
namespace BUS
{
  public  class DiaDiemBUS
    {
       public static void Insert(DiaDiem dd)
        {
            DiaDiemDAL ddDAL = new DiaDiemDAL();
           ddDAL.Insert(dd);
        }
        public static void Update(DiaDiem dd)
        {
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            ddDAL.Update(dd);
        }
        public static void Delete(int iD)
        {
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            ddDAL.Delete(iD);
        }
        public static tbDiaDiemCollection Get(string where,
            int pageindex,
            int pagesize,
            string orderby,
            string orderdirection,
            out int total)
        {
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            return ddDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static tbDiaDiemCollection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            return ddDAL.Get(cri.Criter, 0, 0, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
        }
       public static DiaDiem GetByID(int iD)
       {
           int total = 0;
           Criteria cri = new Criteria();
           cri.add(Condition.AND, tbDiaDiemColumns.MaDD.ToString(), Condition.EQUAL, iD);
           DiaDiemDAL ddDAL = new DiaDiemDAL();
           tbDiaDiemCollection diadiemcollection = ddDAL.Get(cri.Criter,
                 0, 0, tbDiaDiemColumns.MaDD.ToString(), OrderDirection.ASC.ToString(), out total);
           if (diadiemcollection.Count > 0)
               return diadiemcollection[0];
           return null;
       }
      
        public static tbDiaDiemCollection GetLimited(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            return ddDAL.Get(cri.Criter, 1, number,
             tbDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
        public static tbDiaDiemCollection GetPromotion(int number)
        {
            int total = 0;
            Criteria cri = new Criteria();
            DiaDiemDAL ddDAL = new DiaDiemDAL();
            return ddDAL.Get(cri.Criter, 1, number,
               tbDiaDiemColumns.MaDD.ToString(), OrderDirection.DESC.ToString(), out total);
        }
    }
    

    
}
